package com.wcity.manage.dao.mapper;

import com.wcity.manage.dao.dal.BaseMapper;
import com.wcity.manage.dao.model.UserModule;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * Created by jn on 2016/12/8.
 * 用户模块dao
 */
@Repository
public interface UserModuleMapper extends BaseMapper<UserModule,Serializable> {

    /**
     * 查询用户自定义模块
     * @param userId
     * @return
     */
    List<UserModule> findUserModule(@Param("userId")int userId);

    /**
     * 查询用户自定义模块id
     * @param userId
     * @return
     */
    @Select(" select module_id from td_manage_module_user where user_id = #{userId} order by sort desc ")
    List<Integer> findUserModuleIds(@Param("userId")int userId);

    /**
     * 按 用户 模块 删除
     * @param userId
     * @param moduleId
     * @return
     */
    @Delete(" delete from td_manage_module_user where user_id = #{userId} and module_id = #{moduleId} ")
    int deleteByModule(@Param("userId") int userId,@Param("moduleId")int moduleId);

}
